<?php
/*
Plugin Name: Dictionary
Plugin URI: 
Version: v1.0
Author: <a href="http://huynhuan.wordpress.com">HuanHH</a>
Description: Power by bizonline.com.
*/
?>
<?php 
class Dictionary extends WP_Widget {

	function Dictionary() {
		$widget_ops = array('classname' => 'dictionary', 'description' => 'Dictionary' );
		$control_ops = array ('width' => '200', 'height' => '400');
		$this->WP_Widget('dictionary', 'Dictionary', $widget_ops, $control_ops);
	}
	
	function widget($args, $instance) {
		extract($args);
		extract($instance);
		
		?>
		
		<div>
			<h2 class="widgettitle"><?php print $title; ?></h2>
			<form action="<?php print home_url()?>" method="get">
				<div style="float: left; padding-top:5px; text-align:left" align="left">
					  <div width="205" align="left">
						  <select name="dict" id="gdict" class="ginputform" onchange="changeDictionary(this.value);" style="width:100%; font-weight:normal; font-size:10px; color:#666666">
							<option value="1" <?php if ($dict == 1 ) { echo 'selected="selected"';}?> > English - Vietnamese dictionary</option>
							<option value="2" <?php if ($dict == 2 ) { echo 'selected="selected"';}?>> Vietnamese - English dictionary</option>
						  </select><br />

						  <input type="text" name="word" value="<?php echo $word; ?>" style="width:97%;"/>
					  </div>
					  <div width="205" align="center">
						<input type="submit" name="searchaction" value="Tìm" class="ginputform" /> 
					  </div>
					  <br />
				</div>
				<div style="clear:both"></div>
			</form>
		</div>
		<?php
	}

	function update($new_instance, $old_instance) {
		$instance = $old_instance;

		$title = $new_instance['title'];
		
		$instance = compact('title');
		return $instance;
	}

	function form($instance) {
		$defaults=array(
			'title' => __('DICTIONARY', 'bizonline')
		);
		
		$options = wp_parse_args($instance, $defaults);
		extract($options);

		?>

		<div>
			<div>Title label:</div>
			<div><input  id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" /></div>
		</div>

		<?php
	}
}

if (class_exists("Dictionary")) {
	$dictionary = new Dictionary();
}

function register_dictionary() {
	register_widget('Dictionary');
}
add_action('widgets_init', 'register_dictionary');

?>
